/***********************************************************

Filename: TriMesh.h

Description:

This class represents the mesh object. Read and save methods are
added. New properties are added.

Author: Shaoting Zhang

***********************************************************/

#ifndef _TRIMESH_H__
#define _TRIMESH_H__

#ifdef _MSC_VER
#  pragma warning(disable: 4100)
#endif

#include <OpenMesh/Core/IO/MeshIO.hh>
#include <OpenMesh/Core/IO/Options.hh>
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
#include <OpenMesh/Core/Geometry/VectorT.hh>
#include <math.h>

struct TriMeshTraits : public OpenMesh::DefaultTraits
{
	typedef OpenMesh::Vec3d Point;
	typedef OpenMesh::Vec3d Normal;

	VertexAttributes  ( OpenMesh::Attributes::Normal );
	FaceAttributes    ( OpenMesh::Attributes::Normal );
};

class TriMesh : public OpenMesh::TriMesh_ArrayKernelT<TriMeshTraits>
{
public:
	TriMesh(void);
	virtual ~TriMesh(void);

private:
	Point bbox_min, bbox_max;

public:
	void needBoundingBox();

	Point getSceneCenter() { return (bbox_min + bbox_max) / 2.0; };
	double getSceneRadius() { return (bbox_max-bbox_min).norm() / 2.0; };
	void request_curvature();
	void request_curvature_color();
	// get mesh statistics
	void getMeshStat(std::vector<double> &meshStat, TriMesh* meshCopy);

public:
	static TriMesh* read(const char* filename, OpenMesh::IO::Options* opt = NULL);
	static bool save(const char* filename, TriMesh* mesh = NULL, OpenMesh::IO::Options* opt = NULL);
};
typedef TriMesh Tri_Mesh;
typedef TriMesh OMT;
#endif // _TRIMESH_H__
